#define _CRT_SECURE_NO_WARNINGS	

#include<stdio.h>


void Quick_Sort(int arr[], int left, int right)
{
    if (left >= right)
        return;

    int tmp = arr[left];

    int l = left, r = right;

    while (l < r)
    {
        while (r > l && arr[r] >= tmp)
            r--;
        arr[l] = arr[r];

        while (l < r && arr[l] <= tmp)
            l++;
        arr[r] = arr[l];
    }

    arr[l] = tmp;

    Quick_Sort(arr, left, l - 1);
    Quick_Sort(arr, l + 1, right);
}

void Swap(int* x, int* y)
{
    int tmp = *x;
    *x = *y;
    *y = tmp;
}

void Median_Three_Digit(int arr[], int left, int right)
{
    int mid = (left + right) / 2;
    
    if (arr[left] > arr[mid])
        Swap(&arr[left], &arr[mid]);
    
    if (arr[right] < arr[mid])
        Swap(&arr[mid], &arr[right]);

    if (arr[left] > arr[mid])
        Swap(&arr[left], &arr[mid]);
}

int main()
{
    int arr[10] = { 54,34,5,9,83,6,89,12,31,98 };

    Quick_Sort(arr, 0, 9);

    for (int i = 0; i < 10; i++)
        printf("%d ", arr[i]);

    return 0;
}